package com.aegean.MonitorExamSYS.examinee.action;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.aegean.MonitorExamSYS.examinee.business.ExamineeBusiness;
import com.opensymphony.xwork2.ActionSupport;
@Controller("ValidateConductionPersonCount")
@Scope("prototype")
public class ValidateConductionPersonCount extends ActionSupport {
	@Resource
	ExamineeBusiness business;
	private int conduction_Id;
	private String startTime;
	private String endTime;
	private int exam_Id;
	private int personCount;
	private int includeCount;
	private boolean success;
	private String msg;
	public boolean isSuccess() {
		return success;
	}
	public void setSuccess(boolean success) {
		this.success = success;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public int getExam_Id() {
		return exam_Id;
	}
	public void setExam_Id(int exam_Id) {
		this.exam_Id = exam_Id;
	}
	public int getConduction_Id() {
		return conduction_Id;
	}
	public void setConduction_Id(int conduction_Id) {
		this.conduction_Id = conduction_Id;
	}
	public String getStartTime() {
		return startTime;
	}
	public void setStartTime(String startTime) {
		this.startTime = startTime;
	}
	public String getEndTime() {
		return endTime;
	}
	public void setEndTime(String endTime) {
		this.endTime = endTime;
	}
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		personCount=business.countOfcurrentExamAvailablePersonCount(conduction_Id, startTime, endTime);
		includeCount=business.countOfcurrentAppliedPersonCount(exam_Id, conduction_Id);
		if(personCount>includeCount){
			success=true;
		}else{
			success=false;
			msg="对不起,该考点报名名额已满，如果继续报名您可能被安排到其他考场,如果考点出现名额空缺您可能被插入,请您慎重选择！";
		}
		return SUCCESS;
	}
	
}
